import 'dart:async';

import 'package:bloc/bloc.dart';
import 'package:equatable/equatable.dart';
import 'package:flutter_shop_z/model/category_sub.dart';

part 'category_sub_event.dart';
part 'category_sub_state.dart';

class CategorySubBloc extends Bloc<CategorySubEvent, CategorySubState> {
  CategorySub categorySub;
  CategorySubBloc() : super(CategorySubInitialState(null));

  @override
  Stream<CategorySubState> mapEventToState(
    CategorySubEvent event,
  ) async* {
    if (event is SetCategorySubEvent) {
      yield* _mapCategorySubEventToState(event);
    }
  }

  Stream<CategorySubState> _mapCategorySubEventToState(
    SetCategorySubEvent event,
  ) async* {
    this.categorySub = event.categorySub;
    yield CategorySubChangeState(this.categorySub);
  }
}
